		**********************************************************
		** File: creating_WB_region_codes.do					**
		** Paper: Human Trafficking Indicators: A New Dataset	**
		** Author: Richard Frank								**
		** Date: July 11, 2021									**
		** Task: Cleaning World Bank Region codes				**
 		**********************************************************

	version 16.1 
	
	gen region=0
	*label drop region
	label var region "Dest. World Bank region (1-9)"

**************************
** 1 Sub-SAHARAN AFRICA **
**************************
** CREATE REGION LABELS **

label define region 1 "East & Southern Africa" 2 "West & Central Africa" 3 "East Asia & Pacific" 4 "South Asia"  5 "Eastern Europe"  6 "Western Europe" 7 "Middle East"  8 "North Africa" 9 "Americas" 
	*1 East & Southern Africa"
	*Angola	1
	replace region=1 if ccode==540
	*Botswana	1
	replace region= 1 if ccode==571
	*Burundi	1
	replace region= 1 if ccode==516
	*Zaire (Congo)	1
	replace region= 1 if ccode==490
	*Zambia	1
	replace region= 1 if ccode==551
	*Zimbabwe	1
	replace region= 1 if ccode==552
	*Djibouti	1
	replace region= 1 if ccode==522
	*Eritrea	1
	replace region= 1 if ccode==531
	*Ethiopia	1
	replace region= 1 if ccode==530
	*Comoro Is	1
	replace region= 1 if ccode==581
	*Lesotho	1
	replace region= 1 if ccode==570
	*Kenya	1
	replace region= 1 if ccode==501
	*Madagasgar	1
	replace region= 1  if ccode==580
	*Malawi	1
	replace region= 1 if ccode==553
	*Mauritius	1
	replace region= 1 if ccode==590
	*Mozambique	1
	replace region= 1 if ccode==541
	*Namibia	1
	replace region= 1 if ccode==565
	*Rwanda	1
	replace region= 1 if ccode==517
	*Seychelles	1
	replace region= 1 if ccode==591

**********************************
** 2 WESTERN AND CENTRAL AFRICA **
**********************************


	*Benin	2
	replace region= 2 if ccode==434
	*Burkina Faso	2
	replace region= 2 if ccode==439
	*Cameroon	2
	replace region= 2 if ccode==471
	*Cape Verde	2
	replace region= 2 if ccode==402
	*Central Af Rep	2
	replace region= 2 if ccode==482
	*Chad	2
	replace region= 2 if ccode==483
	*Eq Guinea	2
	replace region= 2 if ccode==411
	*Guinea	2
	replace region= 2 if ccode==438
	*Guinea-Bissau	2
	replace region= 2  if ccode==404
	*Ghana	2
	replace region= 2 if ccode==452
	*Congo	2
	replace region= 2 if ccode==484
	*Gabon	2
	replace region= 2 if ccode==481
	*Gambia	2
	replace region= 2 if ccode==420
	*Ivory Coast	2
	replace region= 2 if ccode==437
	*Liberia	2
	replace region= 2 if ccode==450
	*Mali	2
	replace region= 2 if ccode==432
	*Mauritania	2
	replace region= 2 if ccode==435
	*Niger	2
	replace region= 2 if ccode==436
	*Nigeria	2
	replace region= 2 if ccode==475
	*Senegal	2
	replace region= 2 if ccode==433
	*Sierra Leone	2
	replace region= 2 if ccode==451
	
*****************************
** 3 EAST ASIA AND PACIFIC **
*****************************


	*Australia	3
	replace region= 3 if ccode==900
	*Burma	3
	replace region= 3 if ccode==775
	*Cambodia	3
	replace region= 3 if ccode==811
	*China	3
	replace region= 3 if ccode==710
	*China	3
	replace region= 3 if ccode==710.1
	*Fiji	3
	replace region= 3 if ccode==950
	*Japan	3
	replace region= 3 if ccode==740
	*Nauru 3
	replace region=3 if ccode==970
	* Samoa 3
	replace region=3 if ccode==990
	* Palau 3
	replace region=3 if ccode==986
	*Kiribati	3
	replace region= 3 if ccode==946
	*Korea	3
	replace region= 3 if ccode==730
	*Korea	3
	replace region= 3 if ccode==731
	*Korea	3
	replace region= 3 if ccode==732
	* Taiwan 3
	replace region=3 if ccode==713
	*Laos	3
	replace region= 3 if ccode==812
	*Indonesia	3
	replace region= 3 if ccode==850
	* East Timor 3
	replace region= 3 if ccode==860
	*Hong Kong	3
	*Malaysia	3
	replace region= 3 if ccode==820
	* Brunei 3
	replace region= 3 if ccode==835
	*Marshall Is	3
	replace region= 3 if ccode==983
	* Tuvalu 3
	replace region= 3 if ccode==947
	*Micronesia	3
	replace region= 3 if ccode==	987
	*Mongolia	3
	replace region= 3 if ccode==712


******************
** 4 SOUTH ASIA **
******************


	* Afgan	4
	replace region=4 if ccode==700
	*Bangladesh	4
	replace region= 4 if ccode==771
	*Bhutan	4
	replace region= 4 if ccode==760
	*India	4
	replace region= 4 if ccode==750
	*Nepal	4
	replace region= 4 if ccode==790
	*Maldives	4
	replace region= 4 if ccode==781
	*Pakistan	4
	replace region= 4 if ccode==770
	*Sri Lanka	4
	replace region= 4 if ccode==780


**********************************
** 5 EASTERN AND CENTRAL EUROPE **
**********************************
 
	* Albania	5
	replace region=5 if ccode==339
	*Armenia	5
	replace region= 5 if ccode==371
	*Azerbaijan	5
	replace region= 5 if ccode==373
	*Belarus	5
	replace region= 5 if ccode==370
	*Bosnia and Herz.	5
	replace region= 5 if ccode==346
	*Bulgaria	5
	replace region= 5 if ccode==355
	*Estonia	5
	replace region= 5 if ccode==366
	* Kosovo 5
	replace region=5 if ccode==347
	* Montenegro 5
	replace region=5 if ccode==341
	*Croatia	5
	replace region= 5 if ccode==344
	*Kazakhstan	5
	replace region= 5 if ccode==705
	*Czech Rep	5
	replace region= 5 if ccode==316
	*Czechos	5
	replace region= 5 if ccode==315
	*Georgia	5
	replace region= 5 if ccode==372
	*Kyrgyz Rep	5
	replace region= 5 if ccode==703
	*Latvia	5
	replace region= 5 if ccode==367
	*Hungary	5
	replace region= 5 if ccode==310
	*Romania	5
	replace region= 5 if ccode==360
	*Russia	5
	replace region= 5 if ccode==365
	*Moldova	5
	replace region= 5 if ccode==359
	*Lithuania	5
	replace region= 5 if ccode==368
	*Macedonia	5
	replace region= 5 if ccode==343
	*Yugoslavia	5
	replace region= 5 if ccode==345

**********************
** 6 WESTERN EUROPE **
**********************

	* Andorra 6
	replace region=6 if ccode==232
	*Austria	6
	replace region= 6 if ccode==305
	*Belgium	6
	replace region= 6 if ccode==211
	*Denmark	6
	replace region= 6 if ccode==390
	*Finland	6
	replace region= 6 if ccode==375
	*France	6
	replace region= 6 if ccode==220
	* Monaco 6
	replace region=6 if ccode==221
	*Cyprus	6
	replace region= 6 if ccode==352
	*Germany	6
	replace region= 6 if ccode==255
	*Greece	6
	replace region= 6 if ccode==350
	*Liechtenstein	6
	replace region= 6 if ccode==223
	*Ireland	6
	replace region= 6 if ccode==205
	*Italy	6
	replace region= 6 if ccode==325
	*Iceland	6
	replace region= 6 if ccode==395
	*Luxembourg	6
	replace region= 6 if ccode==212
	*Malta	6
	replace region= 6 if ccode==338

*******************
** 7 MIDDLE EAST **
******************* 

	*Bahrain	7
	replace region= 7 if ccode==692
	*Kuwait	7
	replace region= 7 if ccode==690
	*Iran	7
	replace region= 7 if ccode==630
	*Iraq	7
	replace region= 7 if ccode==645
	*Jordan	7
	replace region= 7 if ccode==663
	*Israel	7
	replace region= 7 if ccode==666
	*Lebanon	7
	replace region= 7 if ccode==660

********************
** 8 NORTH AFRICA **
********************

	* Algeria	8
	replace region=8 if ccode==615
	*Egypt	8
	replace region= 8 if ccode==651
	*Tunisia	8
	replace region= 8 if ccode==616
	*Libya	8
	replace region= 8 if ccode==620
	*Morocco	8
	replace region= 8 if ccode==600

****************
** 9 AMERICAS **
****************


	*Antigua&Barbuda	9
	replace region=9 if ccode==58
	*Argentina	9
	replace region=9 if ccode==160
	*Bahamas	9
	replace region= 9 if ccode==31
	*Barbados	9
	replace region= 9 if ccode==53
	*Belize	9
	replace region= 9 if ccode==80
	*Bolivia	9
	replace region= 9 if ccode==145
	*Brazil	9
	replace region= 9 if ccode==140
	*Canada	9
	replace region= 9 if ccode==20
	*Chile	9
	replace region= 9 if ccode==155
	*Colombia	9
	replace region= 9 if ccode==100
	*Costa Rica	9
	replace region= 9 if ccode==94
	*Cuba	9
	replace region= 9 if ccode==40
	*Dom Rep	9
	replace region= 9 if ccode==42
	*Dominica	9
	replace region= 9 if ccode==54
	*Ecuador	9
	replace region= 9 if ccode==130
	*El Salvador	9
	replace region= 9 if ccode==92
	*Grenada	9
	replace region= 9 if ccode==55
	*Guatemala	9
	replace region=9  if ccode==90
	*Guyana	9
	replace region= 9 if ccode==110
	*Haiti	9
	replace region= 9 if ccode==41
	*Honduras	9
	replace region= 9 if ccode==91
	*Jamaica	9
	replace region= 9 if ccode==51
	*Mexico	9
	replace region= 9 if ccode==70
	*Neth Antilles	9
	*Paraguay	9
	replace region= 9 if ccode==150
	*Peru	9
	replace region= 9 if ccode==135
	*Nicaragua	9
	replace region= 9 if ccode==93
	* Cayman Islands  9
	replace region= 9 if country=="Cayman Islands"
	replace region= 9 if country=="Antigua"
	replace region= 9 if country=="Bermuda"	
	replace region= 9 if country=="Martinique"
	
	*Netherlands	6
	replace region= 6 if ccode==210
	*New Zealand	3
	replace region= 3 if ccode==920
	*Norway	6
	replace region= 6 if ccode==385
	*Oman	7
	replace region= 7 if ccode==698
	*Panama	9
	replace region= 9 if ccode==95
	*Papua NG	3
	replace region= 3 if ccode==910
	*Philippines	3
	replace region= 3 if ccode==840
	*Poland	5
	replace region= 5 if ccode==290
	*Portugal	6
	replace region= 6 if ccode==235
	*Qatar	7
	replace region= 7 if ccode==694
	*San Marino	6
	replace region= 6 if ccode==331
	*Sao T&P	2
	replace region= 2 if ccode==403
	*Saudi Arabia	7
	replace region= 7 if ccode==670
	*Singapore	3
	replace region= 3 if ccode==830
	*Slovak Rep	5
	replace region= 5 if ccode==317
	*Slovenia	5
	replace region= 5 if ccode==349
	*Soloman Is	3
	replace region= 3 if ccode==940
	*Somolia	1
	replace region= 1 if ccode==520
	*South Africa	1
	replace region= 1 if ccode==560
	*Spain	6
	replace region= 6 if ccode==230
	*St. Kitts&Nevis	9
	replace region= 9 if ccode==60
	*St. Lucia	9
	replace region= 9 if ccode==56
	*St. Vincent	9
	replace region= 9 if ccode==57
	*Sudan	1
	replace region= 1 if ccode==625
	* South Sudan	1
	replace region= 1 if ccode==620

	*Surinam	9
	replace region= 9 if ccode==115
	*Swaziland	1
	replace region= 1 if ccode==572
	*Sweden	6
	replace region= 6 if ccode==380
	*Switzerland	6
	replace region= 6 if ccode==225
	*Syria	7
	replace region= 7 if ccode==652
	*Tajikistan	5
	replace region= 5 if ccode==702
	*Tanzania	1
	replace region= 1 if ccode==510
	*Thailand	3
	replace region= 3 if ccode==800
	*Togo	2
	replace region= 2 if ccode==461
	*Tonga	3
	replace region= 3 if ccode==955
	*Trin&Tobago	9
	replace region= 9 if ccode==52
	*Turkey	6
	replace region= 6 if ccode==640
	*Turkmenistan	5
	replace region= 5 if ccode==701
	*U Arab Emir	7
	replace region= 7 if ccode==696
	*Uganda	1
	replace region= 1 if ccode==500
	*UK	6
	replace region= 6 if ccode==200
	*Ukraine	5
	replace region= 5 if ccode==369
	*Uruguay	9
	replace region= 9 if ccode==165
	*US	9
	replace region= 9 if ccode==2
	*Uzbekistan	5
	replace region= 5 if ccode==704
	*Vanuatu	3
	replace region= 3 if ccode==935
	*Venezuela	9
	replace region= 9 if ccode==101
	*Viet Nam	3
	replace region= 3 if ccode==816
	*W Samoa	3
	*Yemen AR	7
	replace region= 7 if ccode==678
	*Yemen PDR	0
	replace region= 7 if ccode==680
	*Yemen 7
	replace region= 7 if ccode==679

  label values region region






